package cn.edu.scau.cmi.qiuyaohua.client;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;



public class lei_adaptor extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        AC_220V ac=new AC_220V();
        //Adapt_DC_15V dc=new Adapt_DC_15V();
        Adaptor_DC_15V dc=new Adaptor_DC_15V();
        HBox hbox=new HBox();
        VBox vbox=new VBox();
        ComboBox com=new ComboBox();
        Image image = new Image("image/1.png");
        ImageView view = new ImageView(image);
        GridPane grid=new GridPane();
        TextArea text=new TextArea();
        text.setEditable(false);
        Button button=new Button("显示信息");
        grid.setHgap(40);
        grid.setVgap(40);
        grid.add(new Label("姓名：邱耀华"),0,0);
        grid.add(new Label("学号：201627010120"),0,1);
        grid.add(new Label("选择电压类型："),1,0);
        grid.add(com,1,1);
        grid.add(button,1,3);

        com.getItems().addAll("AC_220V","DC_15V");
        com.setValue("DC_15V");
        hbox.getChildren().addAll(view,grid);
        vbox.getChildren().addAll(hbox,text);

        button.setOnAction(event ->
        {
            switch (com.getValue().toString())
            {
                case "AC_220V":text.setText(ac.display_AC_220V());break;
                case "DC_15V":text.setText(dc.display());break;
            }
        });
        Scene scene = new Scene(vbox);
        primaryStage.setTitle("类适配器方法");
        primaryStage.setScene(scene);
        primaryStage.show();

    }
}
